home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
prog
/
word.arj
/
WGT35.DOC
< prev
next >
Wrap
Text File
|
1993-01-28
|
57KB
|
1,945 lines
WordUp Graphics Toolkit V3.5 Command Reference
Page 1
Copyright 1993 Chris Egerter
WordUp Graphics Toolkit
Command Reference
This document contains all of the available procedures within the
main WGT3.LIB library file. Documentation for WGT menus, scrolling,
and FLI playing are in their own files.
This document is set up to print 66 lines per page. Please report any
errors, typos, or unclear functions to WordUp Software Productions.
All procedures are meant for use in the Large memory model.
Index:
~~~~~~
Video Initialization
~~~~~~~~~~~~~~~~~~~~
vga256............................................4
Graphics Primitives
~~~~~~~~~~~~~~~~~~~
wbar..............................................4
wbutt.............................................4
wcircle...........................................4
wclip.............................................5
wcls..............................................5
wfastputpixel.....................................5
wfill_circle......................................5
wfline............................................6
wgetpixel.........................................6
wline.............................................6
wputpixel.........................................6
wrectangle........................................6
wregionfill.......................................7
wretrace..........................................7
wstyleline........................................7
Colour and Palette
~~~~~~~~~~~~~~~~~~
wcolrotate........................................8
wfade_in..........................................8
wfade_out.........................................8
wloadpalette......................................8
wreadpalette......................................9
wremap............................................9
wsavepalette......................................9
wsetcolor.........................................9
wsetpalette.......................................10
wsetrgb...........................................10
WordUp Graphics Toolkit Command Reference
Page 2
Block Manipulation
~~~~~~~~~~~~~~~~~~
wflipblock........................................11
wfreeblock........................................11
wgetblockheight...................................11
wgetblockwidth....................................11
wloadblock........................................12
wloadcel..........................................12
wloadpak..........................................12
wloadpcx256.......................................13
wnewblock.........................................13
wputblock.........................................14
wsaveblock........................................14
wsavecel..........................................14
wsavepak..........................................15
wsavepcx256.......................................15
Mouse Functions
~~~~~~~~~~~~~~~
minit.............................................15
moff..............................................15
mon...............................................16
mouseshape........................................16
mread.............................................17
msetbounds........................................17
msetspeed.........................................17
msetthreshhold....................................18
noclick...........................................18
Screen Operations
~~~~~~~~~~~~~~~~~
wcopyscreen.......................................19
wnormscreen.......................................19
wsetscreen........................................19
Text functions
~~~~~~~~~~~~~~
wflashcursor......................................20
wfreefont.........................................20
wgettextheight....................................20
wgettextwidth.....................................20
wgtprintf.........................................21
wloadfont.........................................21
wouttextxy........................................21
wsetcursor........................................22
wstring...........................................22
wtextbackground...................................23
wtextcolor........................................23
wtextgrid.........................................23
wtexttransparent..................................24
WordUp Graphics Toolkit Command Reference
Page 3
Special Effects
~~~~~~~~~~~~~~~
wfade.............................................24
wmovescreen.......................................24
wpan..............................................24
wresize...........................................25
wskew.............................................25
wsline............................................25
wvertres..........................................25
wwarp.............................................26
wwipe.............................................27
Sprite Procedures
~~~~~~~~~~~~~~~~~
wloadsprites......................................27
wfreesprites......................................27
WGT Library
~~~~~~~~~~~
setlib procedure..................................28
getlib procedure..................................28
setpassword procedure.............................28
lib2buf procedure.................................29
Timing Control
~~~~~~~~~~~~~~
wtimer............................................29
Joystick Functions
~~~~~~~~~~~~~~~~~~
wcheckjoystick....................................29
winitjoystick.....................................29
wcalibratejoystick................................30
wreadjoystick.....................................30
Additional Library documents:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Multidirectional scrolling........................scroll.doc
SoundBlaster Routines.............................wgtsb.doc
Custom Drop Down Menus............................wgtmenu.doc
Additional Font Information.......................font.doc
FLI playing routines..............................wgtfli.doc
Static Background Sprites.........................wspr.doc
WordUp Graphics Toolkit Command Reference
Page 4
Initialization:
~~~~~~~~~~~~~~~
vga256 procedure
------------------------------------------------------------------------------
Function Initializes the 320x200x256 color graphics mode.
Declaration void vga256(void)
Remarks This command must be called before any other graphics commands
are called or they WILL NOT work.
Graphics Primitives:
~~~~~~~~~~~~~~~~~~~~
wbar procedure
------------------------------------------------------------------------------
Function Draws a filled rectangle with current color on active graphics
page.
Declaration void wbar(int x1,int y1,int x2,int y2)
Remarks See wrectangle.
wbutt procedure
------------------------------------------------------------------------------
Function Draws a 3-Dimensional button, using colours 253-255.
Declaration void wbutt(int x1,int y1,int x2,int y2)
Remarks (x1,y1) define the upper left corner of the button, and
(x2,y2) define the lower right.
See also wsetcolor, wbar
wcircle procedure
------------------------------------------------------------------------------
Function Draws a circle using (x,y) as the center point.
Operates on current color and graphics page.
Declaration void wcircle(int x,int y,int radius)
Remarks The circle is drawn using the current color set by wsetcolor.
Aspect ratios are not used, therefore results may be slightly
different than the BGI counterpart.
See also wsetcolor, wfill_circle
WordUp Graphics Toolkit Command Reference
Page 5
wclip procedure
------------------------------------------------------------------------------
Function Sets the current clipping area for all graphics pages.
Declaration void wclip(int x1,int y1,int x2,int y2)
Remarks (x1,y1) define the upper left corner of the clipping area,
and (x2,y2) defines the lower right. Most WGT drawing
commands will draw within this boundary with a few
exceptions.
Set coordinates to (0,0,319,199) to disable clipping.
wcls procedure
------------------------------------------------------------------------------
Function Clears the currently selected graphics page with a specified
colour number.
Declaration void wcls(int colour)
Remarks This command behaves like the BGI ClearDevice procedure except
that it allows you to use a certain "clearing" color and it
supports WGT's multiple graphics pages.
Restrictions Clears entire page ignoring clipping.
See also wsetscreen,wnormscreen
wfastputpixel procedure
-------------------------------------------------------------------------------
Function Plots a pixel at X,Y. Operates on current graphics page.
Declaration void wputpixel(int x,int y)
Remarks Same as wputpixel only it ignores clipping. This is the
fastest pixel plotting method.
See also wgetpixel,wputpixel
wfill_circle procedure
------------------------------------------------------------------------------
Function Draws a filled circle using (x,y) as the center point.
Declaration void wfill_circle(int x,int y,int radius)
Remarks See wcircle
WordUp Graphics Toolkit Command Reference
Page 6
wfline procedure
------------------------------------------------------------------------------
Function Draws a fast line on the current graphics page from (x1,y1) to
(x2,y2). Operates on current color and graphics page.
No clipping is performed.
Declaration void wline(int x1,int y1,int x2,int y2)
See also wline
wgetpixel procedure
-------------------------------------------------------------------------------
Function Gets the pixel value at X,Y. Uses current graphics page.
Declaration int wgetpixel(int x,int y);
See also wputpixel
wline procedure
------------------------------------------------------------------------------
Function Draws a line on the current graphics page from (x1,y1) to
(x2,y2). Operates on current color and graphics page.
Declaration void wline(int x1,int y1,int x2,int y2)
Remarks Replaces all needs for BGI's line command except where a
line style other than Solid_Line is required. Horizontal lines
are significantly faster than BGI's.
See also wsetcolor,wfline,wstyleline
wputpixel procedure
-------------------------------------------------------------------------------
Function Plots a pixel at X,Y. Operates on current graphics page.
Declaration void wputpixel(int x,int y)
Remarks Plots a point in the current drawing color (set by wsetcolor)
at (x,y).
See also wgetpixel
wrectangle procedure
------------------------------------------------------------------------------
Function Draws a rectangle using the current color and graphics page.
Declaration void wrectangle(int x1,int y1,int x2,int y2)
Remarks (x1,y1) define the upper left corner of the rectangle, and
(x2,y2) define the lower right. Faster than BGI equivalent.
See also wsetcolor, wbar
WordUp Graphics Toolkit Command Reference
Page 7
wregionfill procedure
------------------------------------------------------------------------------
Function Fills an area of the screen bounded by any color other than
that located at (x,y).
Declaration void wregionfill(int x,int y)
Remarks Much more useful than the BGI FloodFill routine. It allows
multiple colors to be used as the border color. You must make
sure the stack size is large enough to handle complex fills.
If you get a stack overflow error, put this line at the
start of your program:
unsigned _stklen= (a number of bytes for the stack,64000 max)
See example program 8 (wgt08.c) for an example of this.
See also wsetcolor
wretrace procedure
------------------------------------------------------------------------------
Function Waits for the vertical retrace.
Declaration void wretrace(void)
Remarks Use when you get flickering graphics. This waits for the
vertical retrace on your monitor, so you can write
to the screen and time it with your monitor. It will
not work perfectly unless you are writing small amounts
to the screen, but it is worth a try if you get flickering
screens.
wstyleline procedure
------------------------------------------------------------------------------
Function Draws a styled line on the current graphics page from (x1,y1) to
(x2,y2). Operates on current color and graphics page.
Declaration void wstyleline(int x1,int y1,int x2,int y2,unsigned in patt)
Remarks Enables a line with different patterns. Patt is an unsigned
int, which means there are 16 bits you can turn on or off.
Each bits represents a pixel in the line turned on or off.
A value of 0 would show no line, while 65535 would be solid.
See also wsetcolor,wline,wfline
WordUp Graphics Toolkit Command Reference
Page 8
Color Manipulation:
~~~~~~~~~~~~~~~~~~~
wcolrotate procedure
------------------------------------------------------------------------------
Function Cycles the colors within a specified group from a palette
variable.
Declaration void wcolrotate(int start,int finish,int dir,color palette[256])
Remarks This routine takes the colors from Start to Finish and shifts
them one in the direction specified by direction. Direction
can either be 0 for up, or 1 for down. This effect can
be used to simulate animation.
See also wsetrgb, wfade_in, wfade_out
wfade_in Procedure
------------------------------------------------------------------------------
Function Gradually fades in a group of colors from a palette variable
(using a specified speed).
Declaration void wfade_in(int start,int finish,int speed, color palette[256]);
Remarks The colors from Start to Finish are faded in starting from
black. The speed may range from (0..255), and is similar to
using the DELAY command between each change of the colors.
The palette array is restored after the fading is finished.
See also wfade_out, wsetrgb, wsetpalette
wfade_out procedure
------------------------------------------------------------------------------
Function Gradually fades out a group of colors from a palette variable
(using a specified speed).
Declaration void wfade_out(int start,int finish,int speed,color palette[256]);
Remarks Same as wfade_in except colors fade from palette to black.
See also wfade_in, wsetrgb, wsetpalette
wloadpalette procedure
------------------------------------------------------------------------------
Function Load a 768 byte palette file from disk into a palette
variable.
Declaration void wloadpalette(char *filename,color *palette)
Remarks Palette files created by WGT or popular graphics programs may
be loaded into the variable specified by palette. Changes are not
made to the currently displayed palette. A good example of
compatibility would be the AutoDesk Animator. It's .COL files
are of this type. Many commercial games use these files as
well.
See also wsavepalette, wsetpalette, wsetrgb
WordUp Graphics Toolkit Command Reference
Page 9
wreadpalette procedure
------------------------------------------------------------------------------
Function Reads the palette into memory.
Declaration void wreadpalette(int start,int finish, color *palette)
Remarks Start and Finish can range from 0 to 255.
Stores the palette info into your palette array.
See also wsetpalette, wloadpalette, wsavepalette, wsetcolor
wremap procedure
------------------------------------------------------------------------------
Function Remaps the colours of a block or the visual screen to a new
palette.
Declaration void wremap(color pal1[256],block remapblock,color pal2[256])
Remarks Pal1 is the palette of the correct palette belonging to
block remapblock. Pal2 contains the new palette the block
will use after remapping. This changes every pixel
in the block from the normal palette, to the closest colour
from the new palette pal2.
If remapblock is NULL, the visual screen is used.
See also wloadpalette, wloadblock
wsavepalette procedure
------------------------------------------------------------------------------
Function Save a palette variable's contents to a disk file.
Declaration void wsavepalette(char *filename, color *palette);
Remarks Creates a 768 byte palette file to disk from a variable
specified by palette. This is useful for storing different
palettes for games and their various screens.
See also wloadpalette, wsetpalette, wsetrgb
wsetcolor procedure
------------------------------------------------------------------------------
Function Sets the current drawing color using the palette.
Declaration void wsetcolor(int color)
Remarks Color may be in the range (0..255). All drawing procedures
used after setting this will use the color you choose.
See also wsetrgb,wsetpalette,wloadpalette,wsavepalette
WordUp Graphics Toolkit Command Reference
Page 10
wsetpalette procedure
------------------------------------------------------------------------------
Function Sets a group of colors from a specified palette variable.
Declaration void wsetpalette(int start,int finish, color *palette)
Remarks Colors from Start to Finish are set using the values stored
in the Palette variable. The variable type PALETTE is
specific to WGT and may not be used elsewhere. It is
defined as follows:
typedef struct {
unsigned char r,g,b;
} color;
To define a palette, you must make an array of colors like
this:
color palette[256];
The Red,Green, and Blue values are in the range (0..63)
giving a total of 262144 color combinations possible.
See also wsetrgb, wloadpalette, wsavepalette, wsetcolor
wsetrgb procedure
------------------------------------------------------------------------------
Function Sets a color's red, green, and blue values.
Declaration void wsetrgb(int color,int red,int green, int blue, color *palette)
Remarks Color can range from 0 to 255.
The Red,Green, and Blue values are in the range (0..63)
giving a total of 262144 color combinations possible.
The colors do NOT change until you give a wsetpalette
command. This way you can set a number of colors
and change them at the same time.
Since the palette is stored as an array, not a pointer, you
must use the & sign when you pass the palette. EG:
color palette[256]; // palette defined
wsetrgb(1,63,63,63,&palette); // sets color 1 to white
See also wsetpalette, wloadpalette, wsavepalette, wsetcolor
WordUp Graphics Toolkit Command Reference
Page 11
Block Manipulation:
~~~~~~~~~~~~~~~~~~~
wflipblock procedure
------------------------------------------------------------------------------
Function Flips a block in one of two directions (block is physically
changed in memory, not on screen).
Declaration void wflipblock(block blockname, int direction);
Remarks This procedure will flip a previously stored image either
vertically or horizontally. The stored image is physically
changed, and therefore the results will not be seen until
the block is displayed.
direction is defined as the following:
#define vertical 0;
#define horizontal 1;
See also wputblock, wnewblock, wresizeblock, wfreeblock
wfreeblock procedure
------------------------------------------------------------------------------
Function Releases memory used to store an image.
Declaration void wfreeblock(block blockname)
Remarks Used when a program is finished with a stored image. This is
similar to the BGI farfree. You must use this to free memory
from all blocks previously allocated by wnewblock or other
block loading procedures before you exit your program,
or you will encounter memory errors.
See also wnewblock
wgetblockheight procedure
------------------------------------------------------------------------------
Function Returns height of a previously stored block.
Declaration int wgetblockheight(block blockname);
wgetblockwidth procedure
------------------------------------------------------------------------------
Function Returns width of a previously stored block.
Declaration int wgetblockwidth(block blockname);
WordUp Graphics Toolkit Command Reference
Page 12
wloadblock procedure
------------------------------------------------------------------------------
Function Loads a previously saved image from disk into a pointer.
Declaration block wloadblock(char *filename)
Remarks wloadblock automatically initializes the appropriate amount
of memory and loads the data. There is no need for a call
to wnewblock (in fact, don't do it or this won't work).
Returns: Pointer to the loaded block. If the block could not be
found on disk, it returns NULL.
See also wsaveblock
wloadcel procedure
------------------------------------------------------------------------------
Function Loads a CEL file (320*200*256 only) into a block.
Declaration block wloadcel(char *filename, color *palette);
Remarks The file MUST be in 320x200x256 color mode. New
Animator Pro CELs can use higher modes and they will not
work. Automatically allocates memory for the block when
you load in the CEL.
wloadpak procedure
------------------------------------------------------------------------------
Function Loads a previously stored image from disk in compressed
format.
Declaration block wloadpak(char *filename)
Remarks This is similar to wloadblock except that the image is
in a file which was created by wsavepak. The compression used
is "similar" to PCX format (sometimes better). The more
simplistic the image, the smaller the file.
Returns: Pointer to the loaded block. If the block could not be
found on disk, it returns NULL.
See also wsavepak, wloadblock
WordUp Graphics Toolkit Command Reference
Page 13
wloadpcx256 procedure
------------------------------------------------------------------------------
Function Loads a PCX file (320*200*256 only) onto the current graphics
page.
Declaration block wloadpcx256(char *filename, color *palette);
Remarks The file can be any size and must be in 256 color mode.
New version looks for the palette at the end of the PCX file.
Some PCX pictures have older formats, depending on
what program created them. For this reason, try not to
depend on PCX pictures too much, and find other methods
such as CEL, or GIF2BLK to import pictures.
wnewblock procedure
------------------------------------------------------------------------------
Function Stores a section of the screen in memory at a location pointed
to by a pointer variable.
Declaration block wnewblock(int x1,int y1,int x2,int y2)
Remarks Dynamic memory is used to automatically calculate the size of
the data, and to store it in a format compatible with BGI's
GETIMAGE. This procedure replaces the need for the combination
of IMAGESIZE, FARMALLOC, and GETIMAGE used in the BGI (although
all of WGT's block commands may be used with
the BGI versions). Simply define a block at the beginning of
your program and call this routine.
example:
block something;
void main(void)
{
...
something=wnewblock(50,50,60,60);
...
}
See also wgetblockwidth, wgetblockheight, wflipblock, wputblock,
wresizeblock, wfreeblock, wloadblock, wsaveblock, wloadpak,
wsavepak
WordUp Graphics Toolkit Command Reference
Page 14
wputblock procedure
------------------------------------------------------------------------------
Function Plots a previously stored image on the current graphics page.
Declaration void wputblock(int x,int y, block blockname, int mode)
Remarks This is similar to the BGI PUTIMAGE. It displays an image
starting from the upper left corner at (x,y). Two modes are
supported for the method. They are:
0 = Normal
1 = XRay
The XRay uses the 0 color as a sort of
"see-through" color. Any occurrence of this color is not
drawn on the screen. This is useful for drawing sprites
which overlay a background screen.
See also wnewblock
wsaveblock procedure
------------------------------------------------------------------------------
Function Saves a previously stored image to a file on disk.
Declaration int wsaveblock(char *filename, block blockname)
Remarks A file is created which holds the data stored at the pointer
given by BLOCKNAME. This allows your programs to load in
images for use later.
Returns: 0 if successful, 1 if it could not save the file
See also wloadblock, wnewblock, wfreeblock
wsavecel procedure
------------------------------------------------------------------------------
Function Saves a CEL file
Declaration void wsavecel(char *filename,block saveblock,color palette[256]);
Remarks This allows you to easily save a block into the CEL format,
so you can load them into AutoDesk's Animator.
WordUp Graphics Toolkit Command Reference
Page 15
wsavepak procedure
------------------------------------------------------------------------------
Function Saves a block to disk in compressed format.
Declaration int wsavepak(char *filename,block blockname)
Remarks This is similar to wsaveblock except that the image is
in a file which is compressed. The compression used
is "similar" to PCX format (sometimes better). The more
simplistic the image, the smaller the file. The image
still requires the same amount of memory, but takes
up less disk space.
Returns: 0 if succesful, 1 if it could not save the file
See also wloadpak, wloadblock
wsavepcx256 procedure
------------------------------------------------------------------------------
Function Saves a block to disk in PCX compressed format.
Declaration int wsavepcx256(char *filename,block blockname,color pal[256])
Remarks This is similar to wsaveblock except that the image is
in a file which is compressed. The PCX compression method
is used. The more simplistic the image, the smaller the file.
The image still requires the same amount of memory, but takes
up less disk space. If the picture has many different colours
in it, sometime the PCX will be larger than a normal block.
See also wloadpcx256, wloadblock
Mouse Functions:
~~~~~~~~~~~~~~~~
minit procedure
------------------------------------------------------------------------------
Function Initializes the mouse.
Declaration int minit(void);
Remarks Simply starts up the mouse. You should use this first if you
want to use the mouse.
Returns: Number of buttons on the mouse if driver is found.
See also mon,moff,mread,noclick,msetbounds,mouseshape,msetspeed,
msetthreshhold
moff procedure
------------------------------------------------------------------------------
Function Turns off display of the mouse cursor.
Declaration void moff(void)
See also minit,mon,mread,noclick,msetbounds,mouseshape,msetspeed,
msetthreshhold
WordUp Graphics Toolkit Command Reference
Page 16
mon procedure
------------------------------------------------------------------------------
Function Displays the mouse cursor.
Declaration void mon(void)
Remarks If the mouse is displayed while you are using some drawing
procedures, it will mess up the screen if you move it over
the area being updated. Turn it off during all drawing
procedures.
See also minit,moff,mread,noclick,msetbounds,mouseshape,msetspeed,
msetthreshhold
mouseshape procedure
------------------------------------------------------------------------------
Function Sets the bitmap and hotspot of the mouse cursor.
Declaration void mouseshape(int rowhot,int colhot, void far *bitmap)
Remarks This procedure sets the cursor hotspot as defined by the
variables ROWHOT and COLHOT. Each are in the range (0..15).
The hotspot is the place on the mouse cursor where
the actual coordinates will be returned. Usually the
hotspot is in the top left corner, but you are free
to modify this depending on your mouse cursor shape.
The actual bitmap information is stored in an array of
integers called bitmap. It is defined as follows:
The first 16 words are used to set the cursor shape, while the
last 16 words set the mask. Several shareware programs are
available to create the data required for these cursors if
you are unfamiliar with bit operations.
See also minit,mon,moff,mread,noclick,msetbounds,msetspeed,
msetthreshhold
WordUp Graphics Toolkit Command Reference
Page 17
mread procedure
------------------------------------------------------------------------------
Function Returns the current button pressed, as well as X and Y
coordinates.
Declaration void mread(void)
Remarks Three global variables are updated when you call this
procedure. mx and my are the mouse coordinates, and
but is the button state.
Buttons are commonly returned as 1 for left, 2 for right,
and 4 for the middle button of a 3 button mouse. 0 is returned
if none are pressed.
See also minit,mon,moff,noclick,msetbounds,mouseshape,msetspeed,
msetthreshhold
msetbounds procedure
------------------------------------------------------------------------------
Function Sets the area to confine the mouse cursor to.
Declaration void msetbounds(int minx,int miny,int maxx,int maxy)
Remarks The cursor will be restricted movement within the specified
region after this routine is called.
See also minit,mon,moff,mread,noclick,mouseshape,msetspeed,
msetthreshhold
msetspeed procedure
------------------------------------------------------------------------------
Function Sets the speed of the mouse.
Declaration void msetspeed(int x_speed,int y_speed)
Remarks Sets the speed of the mouse in each direction. 10 is about
average for both values. 1 is fast, 40 is slower.
In other words, if you set the speed to be 40 for the x, and
1 for the y, you will have to move the mouse a greater
distance horizontally to move the cursor one pixel. On the
other hand, you can move the cursor very quickly up and down.
See also minit,mon,moff,mread,noclick,msetbounds,mouseshape,
msetthreshhold
WordUp Graphics Toolkit Command Reference
Page 18
msetthreshhold procedure
------------------------------------------------------------------------------
Function Sets the speed the mouse must be before it doubles its
movements.
Declaration void msetthreshhold(int speed)
See also minit,mon,moff,mread,noclick,msetbounds,mouseshape,msetspeed
noclick procedure
------------------------------------------------------------------------------
Function Waits until all buttons are released.
Declaration void noclick(void)
Remarks This is useful if you want the user to click on a button,
update something, and wait for another button click.
Without this command, the user could hold down the button
and the program will think you pressed it a bunch of times.
Put this command in after you have found the user pressed
a button. Example:
mread();
if (but==1)
{
ctr++;
noclick();
}
See also minit,mon,mread,msetbounds,mouseshape,msetspeed,
msetthreshhold
WordUp Graphics Toolkit Command Reference
Page 19
Screen Operations:
~~~~~~~~~~~~~~~~~~
wcopyscreen procedure
------------------------------------------------------------------------------
Function Copies a section of one screen onto a different virtual page.
Declaration void wcopyscreen(int x1,int y1,int x2,int y2,block source,
int dx,int dy, block dest)
Remarks This command can seem confusing, but is very powerful, and
necessary when using multiple graphics pages. A second page
must be initialized by getting a block with dimensions
(0,0)-(319,199) before this command can be used.
The area defined by (x1,y1,x2,y2) is copied from the screen
described by SOURCE, and is placed with the upper left corner
at (dx,dy) on the screen referred to by DEST. For example,
to copy screen SECOND(entirely) to the screen FIRST, type
wcopyscreen(0,0,319,199,SECOND,0,0,FIRST). The visual page
can be accesed by replacing the destination or source with
NULL.
For example to copy FIRST to the visual page:
wcopyscreen(0,0,319,199,FIRST,0,0,NULL);
or the other way around:
wcopyscreen(0,0,319,199,NULL,0,0,FIRST);
wnormscreen procedure
------------------------------------------------------------------------------
Function Sets the active page back to the original visual page
Declaration void wnormscreen(void)
Remarks This is used to return all drawing operations to the normal
screen.
See also wnewblock,wfreeblock
wsetscreen procedure
------------------------------------------------------------------------------
Function Makes all drawing procedures use a different video page
Declaration void wsetscreen(block screenname)
Remarks The screen must be first initialized by using wnewblock
with coords 0,0 to 319,199.
See also wnewblock,wfreeblock
WordUp Graphics Toolkit Command Reference
Page 20
Text functions:
~~~~~~~~~~~~~~~
wflashcursor procedure
------------------------------------------------------------------------------
Function Flash the cursor using the values set by wsetcursor and
the global variable curspeed.
Declaration void wflashcursor(void)
Remarks Uses the cursor coordinates set by the global variables
xc and yc. Curspeed is another global variable which can
be set to change the flashing speed.
wfreefont procedure
------------------------------------------------------------------------------
Function Frees memory previously allocated for a font.
Declaration void wfreefont(wgtfont yourfont)
wgettextheight procedure
------------------------------------------------------------------------------
Function Returns the maximum height of the string.
Declaration int wgettextheight(char *printme,wgtfont prfont)
wgettextwidth procedure
------------------------------------------------------------------------------
Function Returns the width of the string.
Declaration int wgettextheight(char *printme,wgtfont prfont)
WordUp Graphics Toolkit Command Reference
Page 21
wgtprintf procedure
------------------------------------------------------------------------------
Function Similar to outtextxy only allows for type conversions
using the same format as printf.
Declaration void wgtprintf(int xloc,int yloc,wgtfont wgtprfon,char *fmt, ... )
Remarks Allows the user to print to the screen using the same
format as the printf command from Turbo C.
The text is printed at the screen coordinates xloc,yloc,
and uses the font wgtprfon. The format is the same as
the printf command, so you can easily print numbers
within strings very easily.
Example:
wgtprintf(30,40,bigfont,"Hello %s! You are %i years old.",name,years);
wloadfont procedure
------------------------------------------------------------------------------
Function Loads a WGT font and return a pointer to it.
Declaration wgtfont wloadfont(char *fontfile)
Remarks Fonts can be used with outtextxy, wgtprintf, or wstring.
Custom fonts are created with the sprite creator,
and converted to font files with spr2fnt.exe.
Example:
myfont=wloadfont("tiny.wfn");
See also wouttextxy, wstring,wfreefont
wouttextxy procedure
------------------------------------------------------------------------------
Function Outputs a string of text on the graphics page at (x,y).
Declaration void wouttextxy(int x,int y, char *string,wgtfont font)
Remarks Same as BGI version except it uses bitmapped fonts.
X/Y coordinate system may be 40*25 or 320*200 (see the
wtextgrid procedure). Uses font for displaying custom
characters. Use wloadfont to load in custom fonts.
In place of the wgtfont, use NULL to display text with
the default font (built in).
See also wtextcolor, wtextbackground, wtextgrid, wtexttransparent,
wtextcursor, wstring,wloadfont
WordUp Graphics Toolkit Command Reference
Page 22
wsetcursor procedure
------------------------------------------------------------------------------
Function Sets the shape of the text cursor.
Declaration void wsetcursor(int y,int y2)
Remarks Y and Y2 coordinates are the coordinates for the upper and
lower lines for a box 8 pixels wide. The X coordinates are
fixed to 8 pixels wide. The cursor is not the hardware text
cursor, but rather a software simulation which flashes during
text input. A solid box would be (0,7).
See Also wstring
wstring procedure
------------------------------------------------------------------------------
Function Reads in a string of text from the keyboard and displays
both the text and a simulated cursor on the graphics page.
Declaration int wstring(int x,int y, char *instring, char *legal, int num,wgtfont
font)
Remarks X and Y are the coordinates to read the string in from.
This procedure uses the flashing cursor while you input the
string. Any characters you wish to be able to type in must
be included in LEGAL. For example, if you want a yes or
no answer only, make LEGAL="YNyn". NUM is the maximum number
of letters in the string.
INSTRING must be a pointer to char, example
char *filename;
Along with legal:
char *legal_chars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz1234567890_.";
Then, you must allocate memory for the string, like this:
filename = (char *) malloc (13);
Add 1 to the length for the null terminator.
Call the string procedure:
wstring(10,22,filename,legal_chars,12);
After you're done with the string, free the memory by
free(filenameout);
INSERT,DELETE,HOME,END and the arrow keys are functional,
backspace is destructive.
If you press insert, the cursor shape changes and toggles
between insert and overwrite modes.
See Also wtextcolor, wtextbackground, wtextgrid, wtexttransparent
WordUp Graphics Toolkit Command Reference
Page 23
wtextbackground procedure
------------------------------------------------------------------------------
Function Sets the background text color.
Declaration void wtextbackground(unsigned char color)
Remarks Color is in the range (0..255). Background may be turned off
for output by using wtexttransparent.
See also wouttextxy,wtextcolor, wtextgrid,
wtexttransparent, wtextcursor, wstring
wtextcolor procedure
------------------------------------------------------------------------------
Function Selects the foreground character color.
Declaration void wtextcolor(unsigned char color)
Remarks Color is in the range (0..255). Foreground may be turned off
during output by setting wtexttransparent.
See also wouttextxy, wtextbackground, wtextgrid,
wtexttransparent, wtextcursor, wstring
wtextgrid procedure
------------------------------------------------------------------------------
Function Switches the text addressing system from 320*200 to 40*25.
Declaration void wtextgrid(int state)
Remarks Text may be output in regular graphics coordinates (320*200) or
a text mode system of 40*25. If STATE is set to 1, all input
and output values for WGT text functions are expected to be
in the 40*25 range. Characters will be 'snapped' to the grid as
if it were a text mode. 0 will use regular graphics system
coordinates.
See Also wouttextxy, wstring
WordUp Graphics Toolkit Command Reference
Page 24
wtexttransparent procedure
------------------------------------------------------------------------------
Function Sets text output to supress display of foreground or
background.
Declaration void wtexttransparent(int mode)
Remarks This will turn off the display of either the foreground or the
background, or set it to show both.
The values possible are:
0: Background turned off
1: Foreground turned off
2: Both turned on
Special Effects
~~~~~~~~~~~~~~~
wfade procedure
------------------------------------------------------------------------------
Function Dissolves a screen of memory onto the active screen.
Declaration void wfade(block sourcescreen, int *pattern, int speed)
Remarks The screen described by SOURCESCREEN is dissolved onto the
active screen set by wsetscreen using the pattern specified
by pattern. Pattern is an array of integer. It can be
defined by the program called dissolve.exe, included with
WGT. After saving a pattern with this program, include the
code generated with your program, and pass it the array to
this procedure.
The speed is a DELAY command after each pixel is copied.
wmovescreen procedure
------------------------------------------------------------------------------
Function Moves an area of the screen in one of four directions.
Declaration void wmovescreen(int x1, int y1, int x2, int y2, int dir,
int amt)
Remarks This is a quick way to scroll an area of the screen by
different amounts. Not recommended for scrolling in games.
DIR: 0=up 1=down 2=left 3=right
wpan procedure
------------------------------------------------------------------------------
Function Changes the offset of the visual screen.
Declaration void wpan(int offset)
Remarks This can be used for special effects to make the screen
shake. Each row contains 320 pixels across. Therefore
the screen will shift up one if the offset is 320.
Offsets with multiples of 320 will shift the screen
up or down, and other offsets with move left or right.
For a shaking effect, use small offsets (0-5).
WordUp Graphics Toolkit Command Reference
Page 25
wresize procedure
------------------------------------------------------------------------------
Function Draws a previously stored image on the screen to fit within a
given boundary.
Declaration void wresize(int x1,int y1,int x2,int y2, block blockname);
Remarks A very fast shrink/expand routine for blocks. It will redraw
an image to fit perfectly within the area defined by
(x1,y1,x2,y2). In this manner, entire screens can be shrunk
down as icons, or small images can "explode". Image in memory
is not affected.
wskew procedure
------------------------------------------------------------------------------
Function Skews a block sideways
Declaration void wskew(int x,int y,block skewblock,int degrees)
Remarks Quickly skews a block by a certain number of degrees
sideways. Excellent for special FX.
wsline procedure
------------------------------------------------------------------------------
Function Operates with the wwarp command. Stores the points of a line
into an array instead of plotting them on the screen.
Declaration void wsline(int x1,int y1,int x2,int y2,int *ptarray);
Remarks Simply stores the y coordinate values in the appropriate
place in the array for every x coordinate on a line.
See wwarp for more info...
wvertres procedure
------------------------------------------------------------------------------
Function Draws a previously stored image on the screen to fit within a
given boundary. Only stretches Y coordinates...much faster!
Declaration void wvertres(int x1,int y1,int y2, block blockname);
Remarks An extremely fast shrink/expand routine for blocks.
Similar to wresize but doesn't change the width of
the block. Use this at all times if you are only
resizing the height, since it is much faster.
WordUp Graphics Toolkit Command Reference
Page 26
wwarp procedure
------------------------------------------------------------------------------
Function Displays a block on the screen, using different heights
for each column displayed.
Declaration void wwarp(int x1,int x2,int *top,int *bot, block blockname);
Remarks Instead of drawing the block straight across in a
rectangular manner, this function resizes the block
vertically for every column displayed. You can have
each column stretched by different amounts allowing
for some very interesting effects.
X1 and X2 are the two x coordinates the block
will be resized between. Top and bot are 320 integer
arrays which hold the y values for every x coordinate.
Blockname is the block to warp.
Use wsline to set up the top and bot arrays if you
are using straight lines.
Example: wsline(0,199,319,0,&top); // sets up line for top
wsline(0,199,319,199,&bot); // sets up bottom line
// Imagine drawing these two lines on the screen...
wwarp(0,319,&top,&bot,warp_block);
The warped block would look like this:
|-----------------------------|
| /--|
| /--/ i |
| /--/ i i i |
| /--/ i i i i i |
| /--/ i i i i i i i |
| /--/ i i This is the i |
| /--/ i i i i warped blocki |
|/i i i i i i i i i i i i i i |
|-----------------------------|
Top should have all points above the corresponding point in bot.
The block is resized between these points on the screen. This method
is fairly slow. If you register WGT 3.0, you will receive full source
code for a faster routine which requires more memory. (20k)
You do not need to use wsline to make straight lines for warping.
Other possibilities include zig-zags, sine waves, etc... Just
put your own numbers into the top and bot arrays and call wwarp.
WordUp Graphics Toolkit Command Reference
Page 27
wwipe procedure
------------------------------------------------------------------------------
Function Draws a line but uses colours from another virtual screen.
Declaration void wwipe(int x1,int y1, int x2,iny y2,block screen)
Remarks This special effect allows you to draw a line on the screen,
but instead of using one colour, each pixel drawn is the
colour of the pixel at the same location on the block
screen. You can created impressive wipes and make your
programs look very professional. You will want to make
one or more 'for' statements that copy the whole screen over
since this only does it one at a time. The lines don't have
to be horizontal or vertical, so you can create complex
patterns with the lines.
Sprite Procedures:
~~~~~~~~~~~~~~~~~~
wloadsprites procedure
--------------------------------------------------------------------------
Function Loads in a sprite file
Declaration int wloadsprites(color *palette,char *filename,
block sprites[1001]);
Loads a sprite file create with the WGT Sprite Creator.
Returns -1 if unsuccessful or 0 if successful
Example usage:
ok=wloadsprites(&palette,"game.spr",sprites);
wfreesprites procedure
--------------------------------------------------------------------------
Function Frees memory from sprites
Declaration void wfreesprites(block sprites[1001]);
Frees memory previously allocated from loadsprites.
Example usage:
wfreesprites(sprites);
WordUp Graphics Toolkit Command Reference
Page 28
WGT Library functions:
~~~~~~~~~~~~~~~~~~~~~~
setlib procedure
------------------------------------------------------------------------------
Function Sets the WGT library name.
Declaration void setlib(char *libname)
Remarks WGT has the ability to store all of your graphics
or data files into one large library file. Use the
utility called wgtlib to manage your WGT library
files. These library files are not the library
files made by TLIB. Set the name of the library
file in the beginning of your program, and all
WGT commands which load something in will use the
library instead of individual files.
Use WGTLIB.EXE to create WGT Library files.
See also getlib,setpassword,lib2buf
getlib procedure
------------------------------------------------------------------------------
Function Gets the WGT library name.
Declaration char *getlib(void)
Remarks Returns the name of the WGT library file in use.
See also setlib,setpassword,lib2buf
setpassword procedure
------------------------------------------------------------------------------
Function Sets the WGT library password.
Declaration void setpassword(char *newpassword)
Remarks WGT library files can be protected by a password.
If you choose the incorrect password, files cannot
be loaded in or modified.
See also getlib,setlib,lib2buf
WordUp Graphics Toolkit Command Reference
Page 29
lib2buf procedure
------------------------------------------------------------------------------
Function Allocates memory for a file, and loads it into memory.
Declaration void *lib2buf(char *filename)
Remarks This allows any type of file to be loaded into
memory from the WGT library file. It gets the required
memory first, and then returns a pointer to the
data. It can be used for many things, such as
text data, sound blaster voc's, cmf files, rol files,
and any other data.
See also getlib,setpassword,setlib
Timing control
~~~~~~~~~~~~~~
int wtimer(struct time t,struct time t2)
-------------------------------------------------------------------------
Returns: Hundredths of seconds between the two times.
Use gettime to store the timing variables first, and call this
routine to see how long it took to execute a command or procedure.
For measuring the frame rate of an animation, count the number of times
the screen is updated, and store the time it took. To find the number of
frames per second, divide the number of updates by the time.
To find the average time it took for each frame, perform the reverse.
This routine can be used to control the timing of animation on different
computer systems. Fast computers will need to be slowed down to
stay at the prefered speed.
WGT Joystick Routines
~~~~~~~~~~~~~~~~~~~~~
***Joystick routines are contained in wgtjoy.lib***
int wcheckjoystick(void)
-------------------------------------------------------------------------
Checks for the presence of each joystick. Returns an integer with 2 bits
set. If bit 1 is set, joystick 1 has been found. If bit 2 is set, joystick
2 has been found.
void winitjoystick(joystick *joy, int joynum)
-------------------------------------------------------------------------
Initializes joystick number joynum. Assumes the joystick is centered.
WordUp Graphics Toolkit Command Reference
Page 30
void wcalibratejoystick(joystick *joy)
-------------------------------------------------------------------------
Calibrates joystick before being used. To calibrate, you must call
this once with the joystick to the upper left, and again with the joystick
to the lower right. This will set the appropriate scale and range of the
joystick.
If you want to calibrate the joystick in a setup program, you can
save all the calibrated values in a configuration file, and load them
back in for your main program. This way the user only has to calibrate
the joystick once.
Here is the structure data you must save:
typedef struct {
int x,y;
int cenx,ceny;
int xrange,yrange;
int port,buttons;
int scale;
} joystick;
int wreadjoystick(joystick *joy)
-------------------------------------------------------------------------
Reads the X, Y, and button status for a joystick.
To read each value, use joy.x,joy.y,joy.buttons.